#include "Grammar.h"


#include "CProduction_Unit.h"
#include "TerminateToken.h"
#include "Expression.h"
#include "Unit.h"
#include "Variable.h"
#include <string>
#include <stdlib.h>

using namespace std;

CTokenPtr CProduction_Unit_Number::Reduce( CProductionArgPtr pArgs )
{
    CTerminateTokenPtr pToken = pArgs->getArg<CTerminateToken>(0);

    int number = atoi(pToken->GetStringValue().c_str());   

    CUnitPtr pResult = CTokenFactory::createToken<CUnit>();

    pResult->m_int = number;

    return pResult;
}

CTokenPtr CProduction_Unit_Variable::Reduce( CProductionArgPtr pArgs )
{
	CTerminateTokenPtr pToken = pArgs->getArg<CTerminateToken>(0);

	CVariablePtr pResult = CTokenFactory::createToken<CVariable>();

	pResult->m_strName = pToken->GetStringValue();

	return pResult;

}